const http = require('http')
const url = require('url')
const querystring = require('querystring')
let application = http.createServer()
application.on('request', (request, response) => {
    let { pathname } = url.parse(request.url)
    // 获取get请求的参数
    let { query } = url.parse(request.url, true)
    // 获取post请求参数
    let postData = ''
    request.on('data', data => {
        postData += data
    })
    request.on('end', () => {
        console.log(querystring.parse(postData));
    })
    if (pathname === '/' || pathname === 'index') {
        response.end('欢迎来到首页')
    } else if (pathname === 'list') {
        response.end('列表页')
    } else {
        response.end('抱歉，没这个页面！')
    }
})
